package com.gugee.ins.common.dal.service.media;

import com.baomidou.mybatisplus.extension.service.IService;
import com.gugee.ins.common.dto.InsAdMediaStInfoDto;
import com.gugee.ins.common.dto.InsMediaScoreDto;
import com.gugee.ins.common.model.es.media.InsMediaIndex;
import com.gugee.ins.common.model.mysql.media.InsMedia;

import java.util.List;

/**
 * insBlogger dao
 * @author Huangxin
 */
public interface InsMediaDao extends IService<InsMedia> {

    /**
     * 更新帖子记录中评论相关字段
     * @param shortcode
     * @param collectCommentCount
     */
    void updateMediaCommentInfo(String shortcode,long collectCommentCount);

    /**
     * 更新帖子是否是广告帖
     * @param shortcode
     * @param isAd
     */
    void updateMediaIsAd(String shortcode,int isAd);

    /**
     * 根据 uid 和 时间 查找数据
     * @param uid
     * @param timeLimit
     * @param commentMinCount
     * @return
     */
    List<InsMedia> findByOwnerUidAndTakenTime(long uid, long timeLimit,int commentMinCount);


    List<InsMediaIndex> findInsMediaIndexByOwnerUidAndTakenTime(long uid, long timeLimit);

    /**
     * 根据uid查找数据
     * @param shortcode
     * @return
     */
    InsMedia findByShortcode(String shortcode);

    /**
     * 统计帖子数
     * @param uid
     * @param timeLimit
     * @param isAd
     * @return
     */
    long countByOwnerUidAndTakenTimeAndAdIs(long uid,long timeLimit, Integer isAd);


    /**
     * 广告帖子占总帖子比例
     * @param uid
     * @param timeLimit
     * @return
     */
    double getAdMediaRate(long uid,long timeLimit);

    /**
     * 统计参与率
     * @param uid
     * @param timeLimit
     * @param isAd
     * @return
     */
    double sumERByOwnerUidAndTakenTimeAndAdIs(long uid,long timeLimit, Integer isAd);

    /**
     * 平均参与率
     * @param uid
     * @param timeLimit
     * @param isAd
     * @return
     */
    double avgERByOwnerUidAndTakenTimeAndAdIs(long uid,long timeLimit, Boolean isAd);

    /**
     * 根据yid 获取标题文本
     * @param uid
     * @param limitMinLength
     * @return
     */
    List<String> findCaptionByUid(long uid,int limitMinLength);

    /**
     * 根据uid 获取需要进行广告帖识别的shortcode
     * @param uid
     * @param limitTime
     * @return
     */
    List<String> findAdMediaIdentifyShortCodeByUid(long uid,long limitTime);

    /**
     * 近30天帖子总数
     * @param uid
     * @param timeLimit
     * @return
     */
    int getMediaTotal(long uid,long timeLimit);

    /**
     * 广告帖子分类统计信息
     * @param uid
     * @param timeLimit
     * @return
     */
    List<InsAdMediaStInfoDto> getAdMediaInfoByUid(long uid, long timeLimit);

    /**
     * 近一周广告帖子统计信息
     * @param uid
     * @param timeLimit
     * @return
     */
    InsAdMediaStInfoDto getAdMediaInfoForWeekByUid(long uid, long timeLimit);

    /**
     * 根据shortcode 更新带货状态
     * @param shortcode
     */
    void updateProductTagType(String shortcode);

    /**
     * 根据uid 和 时间区间获取需要计算分数的近期帖子列表
     * @param uid
     * @param limitTime
     * @return
     */
    List<InsMediaScoreDto> findAnalysisScoreMediaByUid(long uid,long limitTime);

    /**
     * 批量更新 帖子分数
     * @param insMediaScoreDtoList
     */
    void batchUpdateScore(List<InsMediaScoreDto> insMediaScoreDtoList);
}
